#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int main()
{
	int n,c,dp[maxn]={0};
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		dp[i]=n+1;
	while(scanf("%d",&c)!=EOF)
		for(int i=c;i<=n;i++)
			dp[i]=min(dp[i-c]+1,dp[i]);
	if(dp[n]!=n+1) printf("%d",dp[n]);
	else  printf("-1"); 
	return 0;
}
